﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GoodMan.Infrastructure.Entities.Repository;

namespace GoodMan.Infrastructure.Entities.Entity
{
    public class Appraise : IAccessible<T_Appraise, Appraise>, ILogicEntity<T_Appraise, Appraise>
    { 
        public int Id { get; set; }

        public int OrderId { get; set; }

        public int ProductId { get; set; }

        public int AppraiseGrade { get; set; }
         
        public string UserName { get; set; }
         
        public string AppraiseContent { get; set; }

        public DateTime AppraiseDate { get; set; }

        public int State { get; set; }

        public User user { get; set; }

        public Appraise LoadUser(T_User user)
        {
            this.user = new User().Set(user);
            return this;
        }

        protected override void Covariant(T_Appraise model)
        {
            if (model != null)
            {
                this.Id = model.Id;
                this.OrderId = model.OrderId;
                this.ProductId = model.ProductId;
                this.AppraiseGrade = model.AppraiseGrade;
                this.AppraiseContent = model.AppraiseContent;
                this.AppraiseDate = model.AppraiseDate;
                this.UserName = model.UserName;
                this.State = model.State;
            }
        }

        protected override T_Appraise Inverter(Appraise model)
        {
            if (model != null)
            {
                return new T_Appraise()
                {
                    Id=model.Id,
                    OrderId=model.OrderId,
                    ProductId=model.ProductId,
                    AppraiseGrade = model.AppraiseGrade,
                    AppraiseContent=model.AppraiseContent,
                    AppraiseDate=model.AppraiseDate,
                    UserName=model.UserName,
                    State=model.State
                };
            }
            return null;
        }

        public Appraise Set(T_Appraise dbModel)
        {
            Covariant(dbModel);
            return this;
        }
    }
}
